home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWShape.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.8 KB  |  177 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWShape.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWSHAPE_H
  13. #include "FWShape.h"
  14. #endif
  15.  
  16. #ifndef FWFXMATH_H
  17. #include "FWFxMath.h"
  18. #endif
  19.  
  20. // ----- Foundation Includes -----
  21.  
  22. #ifndef FWSTREAM_H
  23. #include "FWStream.h"
  24. #endif
  25.  
  26. //========================================================================================
  27. //    RunTime Info
  28. //========================================================================================
  29.  
  30. #if FW_LIB_EXPORT_PRAGMAS
  31. #pragma lib_export on
  32. #endif
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment FWGraphics_Shape
  36. #endif
  37.  
  38. FW_DEFINE_CLASS_M0(FW_CShape)
  39.  
  40. //========================================================================================
  41. //    class FW_CShape
  42. //========================================================================================
  43.  
  44. //----------------------------------------------------------------------------------------
  45. //    FW_CShape::FW_CShape
  46. //----------------------------------------------------------------------------------------
  47.  
  48. FW_CShape::FW_CShape(FW_ERenderVerbs renderVerb,
  49.                      const FW_PInk& ink,
  50.                      const FW_PStyle& style,
  51.                      const FW_PFont& font) :
  52.     fRenderVerb(renderVerb),
  53.     fInk(ink),
  54.     fStyle(style),
  55.     fFont(font)
  56. {    
  57.     FW_END_CONSTRUCTOR
  58. }
  59.  
  60. //----------------------------------------------------------------------------------------
  61. //    FW_CShape::FW_CShape
  62. //----------------------------------------------------------------------------------------
  63.  
  64. FW_CShape::FW_CShape(const FW_CShape& other):
  65.     fInk(other.fInk),
  66.     fStyle(other.fStyle),
  67.     fFont(other.fFont),
  68.     fRenderVerb(other.GetRenderVerb())
  69. {
  70.     FW_END_CONSTRUCTOR
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------
  74. //    FW_CShape::FW_CShape
  75. //----------------------------------------------------------------------------------------
  76.  
  77. FW_CShape::FW_CShape(FW_CReadableStream& archive)
  78. {
  79.     archive >> fInk;
  80.     archive >> fStyle;
  81.     archive >> fFont;
  82.     archive.Read((char*)&fRenderVerb, sizeof(fRenderVerb));
  83.  
  84.     FW_END_CONSTRUCTOR
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //    FW_CShape::~FW_CShape
  89. //----------------------------------------------------------------------------------------
  90.  
  91. FW_CShape::~FW_CShape()
  92. {
  93.     FW_START_DESTRUCTOR
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    FW_CShape::operator=
  98. //----------------------------------------------------------------------------------------
  99.  
  100. FW_CShape& FW_CShape::operator=(const FW_CShape& other)
  101. {
  102.     if (this != &other)
  103.     {
  104.         fInk = other.fInk;
  105.         fStyle = other.fStyle;
  106.         fFont = other.fFont;
  107.         fRenderVerb = other.fRenderVerb;
  108.     }
  109.     
  110.     return *this;
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    FW_CShape::Purge
  115. //----------------------------------------------------------------------------------------
  116.  
  117. void FW_CShape::Purge()
  118. {
  119. }
  120.  
  121. //----------------------------------------------------------------------------------------
  122. //    FW_CShape::Flatten
  123. //----------------------------------------------------------------------------------------
  124.  
  125. void FW_CShape::Flatten(FW_CWritableStream& archive) const
  126. {
  127.     archive << fInk;
  128.     archive << fStyle;
  129.     archive << fFont;
  130.     archive.Write((char*)&fRenderVerb, sizeof(fRenderVerb));
  131. }
  132.  
  133. //----------------------------------------------------------------------------------------
  134. //    FW_CShape::GetUnSharedInk
  135. //----------------------------------------------------------------------------------------
  136.  
  137. FW_PInk& FW_CShape::GetUnSharedInk()
  138. {
  139.     if (fInk->GetRefCount() > 1)
  140.         fInk = fInk->Copy();
  141.         
  142.     return fInk;
  143. }
  144.  
  145. //----------------------------------------------------------------------------------------
  146. //    FW_CShape::GetUnSharedStyle
  147. //----------------------------------------------------------------------------------------
  148.  
  149. FW_PStyle& FW_CShape::GetUnSharedStyle()
  150. {
  151.     if (fStyle->GetRefCount() > 1)
  152.         fStyle = fStyle->Copy();
  153.         
  154.     return fStyle;
  155. }
  156.  
  157. //----------------------------------------------------------------------------------------
  158. //    FW_CShape::GetUnSharedFont
  159. //----------------------------------------------------------------------------------------
  160.  
  161. FW_PFont& FW_CShape::GetUnSharedFont()
  162. {
  163.     if (fFont->GetRefCount() > 1)
  164.         fFont = fFont->Copy();
  165.         
  166.     return fFont;
  167. }
  168.  
  169. //----------------------------------------------------------------------------------------
  170. //    FW_CShape::Write
  171. //----------------------------------------------------------------------------------------
  172.  
  173. void FW_CShape::Write(FW_CWritableStream& archive, const void* shape)
  174. {
  175.     ((FW_CShape*)shape)->Flatten(archive);
  176. }
  177.